package com.example.administrator.zhongyichou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.administrator.zhongyichou.Bean.BaseEventBean;
import com.example.administrator.zhongyichou.R;
import com.example.administrator.zhongyichou.base.BaseActivity;
import com.example.administrator.zhongyichou.config.Constants;
import com.example.administrator.zhongyichou.net.core.HttpLoader;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;
import com.example.administrator.zhongyichou.view.HeaderView;
import com.example.administrator.zhongyichou.view.MyDialog;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lichenyu on 2017/12/13.
 * 描述：
 */

public class HealthNotificationActivity extends BaseActivity {
    @BindView(R.id.headerview)
    HeaderView headerview;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.txt_disease)
    TextView txtDisease;
    @BindView(R.id.txt_desc)
    TextView txtDesc;
    @BindView(R.id.txt_content)
    TextView txtContent;
    @BindView(R.id.txt_left)
    TextView txtLeft;
    @BindView(R.id.txt_right)
    TextView txtRight;
    private String title;
    private String disease;

    @Override
    protected void init() {
        ButterKnife.bind(this);
        initHead();

    }

    @Override
    protected void responseData(GsonBaseProtocol mGsonBaseProtocal) throws NullPointerException {
        title = getIntent().getStringExtra("title");
        disease = getIntent().getStringExtra("disease");
        txtTitle.setText(title);
        txtDisease.setText(disease);
    }

    @Override
    protected HttpLoader initHttpLoader() {
        return null;
    }

    @Override
    protected int initContentView() {
        return R.layout.health_notification_activity;
    }

    @Override
    public boolean onEventBus(BaseEventBean baseEventBean) {
        return false;
    }

    private void initHead() {
        headerview.setTitle("健康告知");
        headerview.bindOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case HeaderView.LEFT:
                        finish();
                        break;
                }
            }
        });
    }

    @OnClick({R.id.txt_left, R.id.txt_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.txt_left:
                MyDialog dialog = new MyDialog(this);
                dialog.setTxtTitle("");
                dialog.setTxtContent("很抱歉，由于健康情况不符合加入条件，该会员不能参与该互助行动。如有疑问请咨询客服：" + getString(R.string.phone));
                dialog.setTxtCancel("重新确认");
                dialog.setTxtConfirm("查看其它计划");
                dialog.setOnChekedClick(new MyDialog.OnChekedClick() {
                    @Override
                    public void onCancelClick() {

                    }

                    @Override
                    public void onConfirmClick() {
                        EventBus.getDefault().post(new BaseEventBean<>(Constants.TYPE_7));
                        finish();
                    }
                });
                dialog.show();
                break;
            case R.id.txt_right:
                Intent intent = new Intent(this, JoinActionActivity.class);
                startActivity(intent);
                break;
        }
    }
}
